AddCSLuaFile( "cl_init.lua" ) // Make sure clientside
AddCSLuaFile( "shared.lua" ) // and shared scripts are sent.
  
include('shared.lua')
 
function ENT:Initialize()
 
	self.Entity:SetModel( "models/props_junk/wood_crate001a.mdl" )
	self.Entity:PhysicsInit( SOLID_VPHYSICS ) // Make us work with physics,
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) // after all, gmod is a physics
	self.Entity:SetSolid( SOLID_VPHYSICS ) // Toolbox

	self.Entity.contents={}

	local phys = self.Entity:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
	end
end
   
function ENT:Use( activator, caller )
	if ( activator:IsPlayer() ) then
		if(!timer.IsTimer("crate"..activator:UniqueID())) then
			timer.Create("crate"..activator:UniqueID(),1,0 ,function()  timer.Destroy("crate"..activator:UniqueID()) end)
		
			 sendContents(activator,nil,self:EntIndex())
		end
	end 
end
   
function ENT:Think()
  // We don't need to think, we are just a prop after all!
end 

function sendContents(ply,command,arguments)
	umsg.Start("showContents",ply)
	umsg.Long(arguments)
	umsg.Long(table.Count(ents.GetByIndex(arguments).contents))		
		for k,v in pairs(ents.GetByIndex(arguments).contents) do
			umsg.String(k)
			umsg.Long(v)
		end
	umsg.End()
end